import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home/Home.vue'
import Menu from '../views/Menu/Menu.vue'
import Shopbag from '@/views/Shopbag/Shopbag.vue'
import My from '@/views/My/My.vue'
import Good from '@/views/Good/Good.vue'
import Search from '@/views/Search/Search.vue'
import Login from '@/views/Login/Login.vue'
import Account from '@/views/My/Account.vue'
import Like from '@/views/My/Like.vue'
import Myaddress from '@/views/My/Myaddress.vue'
import Secure from '@/views/My/Secure.vue'
import Track from '@/views/My/Track.vue'
import NewAddress from '@/views/NewAddress/NewAddress.vue'
import Pay from '@/views/Pay.vue'
import Order from '@/views/My/Order.vue'
import Forgot from '@/views/Forgot/Forgot.vue'

Vue.use(VueRouter)

const routes = [
  //  一级路由
  {
    path: '/main',
    name: 'Main',
    component: () => import('../views/Main.vue'),
    children: [
      {
        path: 'home',
        name: 'Home',
        component: Home
      },
      {
        path: 'menu',
        name: 'Menu',
        component: Menu
      },
      {
        path: 'shopbag',
        name: 'Shopbag',
        component: Shopbag
      },
      {
        path: 'my',
        name: 'My',
        component: My
      }
    ]
  },
  { path: '/good:pid', name: 'Good', component: Good },
  { path: '/search', name: 'Search', component: Search },
  { path: '/login', name: 'Login', component: Login },
  { path: '/account', name: 'Account', component: Account },
  { path: '/like', name: 'Like', component: Like },
  { path: '/myaddress', name: 'Myaddress', component: Myaddress },
  { path: '/secure', name: 'Secure', component: Secure },
  { path: '/track', name: 'Track', component: Track },
  { path: '/NewAddress', name: 'NewAddress', component: NewAddress },
  { path: '/pay', name: 'Pay', component: Pay },
  { path: '/order', name: 'Order', component: Order },
  { path: '/forgot', name: 'Forgot', component: Forgot },

  //  路由重定向
  {
    path: '*',
    redirect: {
      name: 'Home'
    }
  }
]

const router = new VueRouter({
  routes
})

export default router
